import { Component } from "~/utils/enums"
import * as c from "~/utils/components"
import BaseForm from "@admin/entity/base/BaseForm"


export default class DictData extends BaseForm {
    dictCode = 0
    dictType = ''
    dictLabel = ''
    dictValue = ''
    cssClass = ''
    dictSort = 1
    listClass = ''
    status = ''
    remark = ''


    clear(): void {
        this.resetFields()
        this.setForm(new DictData(this.opts))
    }

    getDictType(): c.Input {
        return {
            type: Component.Input,
            label: '字典类型',
            mode: 'query',
            required: () => this.dictSort == 3,
            element: {
                disabled: this.opts?.name === 'addForm'
            }
        }
    }

    getDictLabel(): c.Input {
        return {
            type: Component.Input,
            label: '字典标签',
            mode: 'query',
            required: true
        }
    }

    getDictValue(): c.Input {
        return {
            type: Component.Input,
            label: '字典键值',
            required: true
        }
    }

    getDictSort(): c.InputNumber {
        return {
            type: Component.InputNumber,
            label: '字典排序',
            events: {
                change: () => { }
            }
        }
    }

    getRemark(): c.Textarea {
        return {
            type: Component.Textarea,
            label: '备注'
        }
    }
}
